import { Body, Controller, Get, Post, Query } from "@nestjs/common";
import { MenuService } from "./menu.service";
import { wrapperResponse } from "src/utils";

@Controller('/menu')
export class MenuController {
    constructor(
        private readonly menuService:MenuService
    ){}
    @Get('/list')
    getMenuList(@Query() query) {
        return wrapperResponse(
            this.menuService.findAll(query),
            '获取菜单成功'
        )
    }

    @Get('/active')
    getActiveMenuList() {
        return wrapperResponse(
            this.menuService.findActive(),
            '获取已启动的菜单成功'
        )
    }

    @Get('/detail')
    getDetail(@Query() query) {
        console.log('query',query);
        
        console.log('id',query.id);
        
        return wrapperResponse(
            this.menuService.findOne(query.id),
            '查看菜单详情'
        )
    }

    @Post('/create')
    createMenu(@Body() body) {
        return wrapperResponse(
            this.menuService.create(body),
            '创建菜单成功'
        )
    }

    @Post('/update')
    updateMenu(@Body() body) {
        return wrapperResponse(
            this.menuService.update(body),
            '更新菜单成功'
        )
    }
    
    @Post('/del')
    deleteMenu(@Body() body) {
        console.log('body',body);
        
        return wrapperResponse(
            this.menuService.delete(body.id),
            '删除菜单成功'
        )
    }

}